import os 
import sys


class PackLua:

	@classmethod
	def pack_lua(cls, bin, path):

		os.chdir(path)
		path_out = os.path.join(os.pardir, "dist")
		if not os.path.isdir(path_out):
			os.mkdir(path_out)
		cmd_str="{lbin} squish --no-minify".format(lbin=bin)
		print(cmd_str)
		ret = os.popen(cmd_str)
		print(ret.read())

	@classmethod 
	def run(cls, projpath):

		path_tool = os.path.join(projpath, "tools")
		path_script = os.path.join(projpath, "script")	
		bin_lua = os.path.join(path_tool, "lua") if sys.platform == "win32" else "lua"
		cls.pack_lua(bin_lua, path_script)


if __name__ == "__main__":
	tar_path = os.path.realpath(os.pardir) 
	PackLua.run(tar_path)